Plugin = { }
Plugin.Name = "UTime"
Plugin.Info = "Simple UTime Replication"
Plugin.Usage = "speaky!"
Plugin.ChatCommand = "utime"

Plugin.First = function()
	function UpDateTime( pl )
		if pl:GetPData("TimeOnServer") == nil then
			pl:SetPData("TimeOnServer", 0)
			return false
		end
		pl:SetPData("TimeOnServer", pl:GetPData("TimeOnServer") + 1 )
	end
end

Plugin.Second = function()
	Msg("\t Loaded Succesfully! \n")
	hook.Add("PlayerInitialSpawn", "ChatBot.Plugin.UTime", function( pl )
		timer.Create("ChatBot.Plugin.UTime." .. pl:Nick(), 60,0, UpDateTime, pl )
	end)
end

Plugin.OnChat = function( player , command , arguments )
	if !arguments or !arguments[1] then
		local miniutes = player:GetPData("TimeOnServer")
		if miniutes == nil then miniutes = 0 end
		local terminal = "s"
		if miniutes == 1 then terminal = "" end
		umsg.Start("ChatBot.Call.UTIME", player)
			umsg.String( player:Nick() .. " Has been on the server for " .. miniutes .. " minute" .. terminal .. ".")
		umsg.End()
		//ChatBot.SendPMessage( player , player:Nick() .. " Has been on the server for " .. miniutes .. " minute" .. terminal .. "." )
	else
		local pl = ChatBot.FindPlayer( arguments[1] )
		if pl then
			local miniutes = ChatBot.FindPlayer( arguments[1] ):GetPData("TimeOnServer")
			if miniutes == nil then miniutes = 0 end
			local terminal = "s"
			if miniutes == 1 then terminal = "" end
			umsg.Start("ChatBot.Call.UTIME", pl)
				umsg.String( ChatBot.FindPlayer( arguments[1] ):Nick() .. " Has been on the server for " .. miniutes .. " minute" .. terminal .. "." )
			umsg.End()
			//ChatBot.SendPMessage( player , ChatBot.FindPlayer( arguments[1] ):Nick() .. " Has been on the server for " .. miniutes .. " minute" .. terminal .. "." )
		end
	end
end
